package com.yyds.blackmagic.service.impl;


import com.yyds.blackmagic.entity.Category;
import com.yyds.blackmagic.mapper.CategoryMapper;
import com.yyds.blackmagic.service.CategoryService;
import com.yyds.blackmagic.vo.ActionResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author yj
 * @description
 * @date
 */
@Service
public class CategoryServiceImpl implements CategoryService {
@Resource
private CategoryMapper categoryMapper;
    @Override
    public List<Category> findAll() {
        List<Category> all = categoryMapper.findAll();
        return all;
    }

    @Override
    public Category findOne(int id) {
        Category one = categoryMapper.findOne(id);
        return one;
    }

    @Override
    public Category updateCategory(Category category) {
        int i = categoryMapper.updateCategory(category);
        if (i>-1){
            return category;
        }
        return null;
    }

    @Override
    public boolean deleteCategory(int id) {
        int i = categoryMapper.deleteCategory(id);
        if (i>-1){
            return true;
        }
        return false;
    }

    @Override
    public Category addCategory(Category category) {
        int i = categoryMapper.addCategory(category);
        if (i>-1){
            return category;
        }
        return null;
}
}
